//============================================================================
// Name        : effective_item_33.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C, Ansi-style
//============================================================================

#include <stdio.h>
#include <stdlib.h>
using namespace std;

#include <iostream>
#include <tr1/memory>
class Base{
   private:
     int x;
   public:
     virtual void mf1() = 0;
     virtual void mf1(int) {std::cout<< "Base::mf1(int)"<<endl;};
     virtual void mf2() { std::cout<<"Base::mf2"<<endl;};
     void mf3() { std::cout<<"Base::mf3()"<<endl;};
     void mf3(double) {std::cout<<"Base::mf3"<<endl;};
     Base() {std::cout<<"Base"<<endl;};
     ~Base(){std::cout<<"~Base"<<endl;};
};
class Derive:public Base{
   public:
     virtual void mf1(){std::cout << "Derive::mf1()"<<endl;}
     void mf3() { std::cout<<"Derive::mf3()"<<endl;};
     void mf4() {std::cout<<"Derive::mf4"<<endl;};
};


//test More effective c++ item M10 start
class Image{
public:
  Image() {std::cout << __PRETTY_FUNCTION__<<endl;};
  ~Image() {std::cout << __PRETTY_FUNCTION__<<endl;};
  void doSomething() {return;};
};

class Audio{
public:
	Audio() { std::cout << __PRETTY_FUNCTION__<<endl;
			std::bad_alloc exception;
			throw exception;
			};
	~Audio(){std::cout << __PRETTY_FUNCTION__<<endl;};
private:

};

class BookEntry{
public:
	BookEntry():theImage(new Image), theAudio(new Audio){
	std::cout << __PRETTY_FUNCTION__<<endl;};
private:
	const std::auto_ptr<Image> theImage;
	const std::auto_ptr<Audio> theAudio;
};

//test More effective c++ item M10 end

int main(void) {
	auto_ptr<Base> pBase(new Derive);
	
	//test More effective c++ item M10 start
	try{
	BookEntry a;
	}catch(...)
	{
		std::cout << __PRETTY_FUNCTION__<<"  "<< "catch exception!"<<endl;
	}

	return EXIT_SUCCESS;
}
